filechoosernativewin32: Set default extension
authorrobxnano <91250-robxnano@users.noreply.gitlab.gnome.org>
Sat, 26 Nov 2022 14:09:40 +0000 (14:09 +0000)
committerrobxnano <91250-robxnano@users.noreply.gitlab.gnome.org>
Sat, 7 Jan 2023 18:21:54 +0000 (18:21 +0000)
Setting the default extension before a filter is selected allows
the IFileDialog to automatically change the extension when the
filter is changed. See:
https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifiledialog-setdefaultextension

gtk/gtkfilechoosernativewin32.c

index bec7ca4be3ba0904418ae778720a1a47e7a46fc3..d2f1769210d77840334bf731f1e2b00ccae6c493 100644 (file)
@@ -610,6 +610,10 @@ filechooser_win32_thread (gpointer _data)
       if (FAILED (hr))
         g_warning_hr ("Can't set file types", hr);
 
+      hr = IFileDialog_SetDefaultExtension (pfd, L"");
+      if (FAILED (hr))
+        g_warning_hr ("Can't set default extension", hr);
+
       if (data->self->current_filter)
         {
           GSList *filters = gtk_file_chooser_list_filters (GTK_FILE_CHOOSER (data->self));